package com.trkj.property_controller;

import com.trkj.entity.HouseholdEntity;
import com.trkj.service.HouseholdService;
import com.trkj.vo.AjaxResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
@CrossOrigin
public class HouseholdController {
    @Autowired
    private HouseholdService householdService;

    @PostMapping("findAllHousehold")
    public AjaxResponse findAllHousehold(@RequestBody HouseholdEntity householdEntity, int currentPage, int PageSize) {
        log.info("查询所有家庭信息");
        return AjaxResponse.success(householdService.findAllHousehold(householdEntity,currentPage,PageSize));
    }
    @PostMapping("addHousehold")
    public Boolean addHousehold(@RequestBody HouseholdEntity householdEntity){
        return householdService.addHousehold(householdEntity);
    }
    @PutMapping("/updateHold")
    public Boolean updateHold(@RequestBody HouseholdEntity householdEntity){
        return householdService.updateHold(householdEntity);
    }
    @DeleteMapping("/delHold")
    public Boolean delHold(@RequestParam("householdId") int householdId){
        return householdService.delHold(householdId);
    }
    @PostMapping("/findBiaoQian")
    public List<HouseholdEntity> findBiaoQian(){
        return householdService.findBiaoQian();
    }

    //查询所有住户数量
    @PostMapping("/ZhuHuList")
    public AjaxResponse ZhuHuList(){
        return AjaxResponse.success(householdService.ZhuHuList());
    }
}
